# Contributor: Brien Dieterle <briend@gmail.com>

_realname=colorspacious
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python2-${_realname}" "${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=1.1.2
pkgrel=3
pkgdesc="Python library for doing colorspace conversions (mingw-w64)"
arch=('any')
license=('MIT')
url="https://pypi.python.org/pypi/colorspacious"
makedepends=("${MINGW_PACKAGE_PREFIX}-python2-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python3-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python2-numpy"
             "${MINGW_PACKAGE_PREFIX}-python3-numpy")
options=('staticlibs')
source=("${_realname}-${pkgver}.tar.gz"::"https://github.com/njsmith/colorspacious/archive/v${pkgver}.tar.gz")
sha256sums=('d72658fe4ccedc3ab276c831e51887ee8fc8e5824eee11aeed398ec77d77d640')

prepare() {
  cd ${srcdir}
  cp -r colorspacious-${pkgver} python2-build
  cp -r colorspacious-${pkgver} python3-build
}

build() {
  cd "${srcdir}"
  for builddir in python{2,3}-build; do
    pushd ${builddir}
    ${MINGW_PREFIX}/bin/${builddir%-build} setup.py build
    popd
  done
}

package_python2-colorspacious() {
  depends=("${MINGW_PACKAGE_PREFIX}-python2")

  cd "${srcdir}/python2-build"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python2 setup.py install --prefix=${MINGW_PREFIX} --root="${pkgdir}" -O1

  install -Dm644 LICENSE.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python2-${_realname}/COPYING"
}

package_python3-colorspacious() {
  depends=("${MINGW_PACKAGE_PREFIX}-python3")

  cd "${srcdir}/python3-build"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python3 setup.py install --prefix=${MINGW_PREFIX} --root="${pkgdir}" -O1

  install -Dm644 LICENSE.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python3-${_realname}/COPYING"
}

package_mingw-w64-i686-python2-colorspacious() {
  package_python2-colorspacious
}

package_mingw-w64-i686-python3-colorspacious() {
  package_python3-colorspacious
}

package_mingw-w64-x86_64-python2-colorspacious() {
  package_python2-colorspacious
}

package_mingw-w64-x86_64-python3-colorspacious() {
  package_python3-colorspacious
}
